#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import os
import random
import ctypes
import time
import requests
# 定义接收到的不同环节码，执行不同逻辑
def foo(var):
        # path = os.path.abspath('./images')
        # filepath = os.path.join(path,var)
        # ctypes.windll.user32.SystemParametersInfoW(20, 0, filepath, 0)  # window系统设定壁纸
        # print(filepath,'py里面接收的参数是')
        filename = f"当前使用壁纸.jpg"
        img_data = requests.get(var)
        print(var,1652)
        with open(filename, "wb")as f:
             f.write(img_data.content)
        # 替换壁纸
        path = os.path.abspath('.')
        #从当前路径读取上一层路径csv文件
        filepath = os.path.join(path,filename)
        ctypes.windll.user32.SystemParametersInfoW(20, 0, filepath, 0)  # window系统设定壁纸


# 参数为从命令行传过来的参数 sys.argv ['py_test.py', arg1, arg2...]
# 所以取参数要从1开始，就是第二位置开始取
foo(sys.argv[1])